/**
 * Created by Dalyn on 2017/3/14.
 */
import React , {Component}from 'react';

import {Modal,Icon} from 'antd';
import "./css/product.css"

export default class BatchHint extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            displayflag:false,
            text:""
        };
        this.deleteflag =false;
        this.hintType="";
        this.operateType="";
    }

    showWindow(displayflag,text,deleteflag) {
        this.setState({
            displayflag:displayflag,
            text:text
        });
        this.deleteflag = false;
        this.hintType = deleteflag;
        this.operateType = deleteflag;
        /*if(deleteflag == "delete"){
            this.deleteflag = true;
        }*/
    }

    onSure(){
        this.setState({
            displayflag:false
        });
        switch (this.operateType){
            case "delete":
                this.props._doDeleteProduct();
                break;
        }
        /*if (this.deleteflag){
            this.props._doDeleteProduct();
        }*/
    }
    handleCancel = () => {
        this.setState({
            displayflag: false,
        });
    };
    iconType(){
        switch (this.hintType){
            case "delete":
                return(
                    <Icon type="exclamation-circle"  className="product_warning" style={{color:"#fc880c"}}/>
                );
                break;
            default:
                return(
                    <Icon type="exclamation-circle"  className="product_warning" style={{color:"#fc880c"}}/>
                );
                break;
        }
    }
    render(){
        return (
            <Modal className="batchhint_modal"
                   title="提示"
                   visible={this.state.displayflag}
                   onCancel={this.handleCancel}
                   onOk={this.onSure.bind(this)}
            >
                <p className="product_hint_text">
                    {
                        this.iconType()
                    }
                    <span className="product_hint_word">{this.state.text}</span>
                </p>
            </Modal>
        )
    }
}